# 拨号步骤
# 创建 vlan id
ip link add link enp2s0 name enp2s0.1 type vlan id 1
ip link set enp2s0.1 up
# 创建 macvlan
ip link add link enp2s0.1 dev mv-1 type macvlan mode bridge
ip link set mv-1 up
#创建 网络空间
ip netns add yfcloud1
# 连接 macvlan 和网络空间
ip link set mv-1 netns yfcloud1
# 网络空间内拨号
ip netns exec yfcloud2 pppd plugin /usr/lib/pppd/2.4.7/rp-pppoe.so mv-2 noipdefault noauth default-asyncmap hide-password nodetach mtu 1460 mru 1460 noaccomp  nodeflate nopcomp novj novjccomp user zjt2 lcp-echo-interval 20 lcp-echo-failure 100 lcp-echo-failure 100 unit 0 debug



ip link add link enp2s0 dev mv-2 type macvlan mode bridge
ip link set mv-2 up
ip netns exec yfcloud2 ip link set mv-2 up

ip link add link enp2s0 dev mv-1 type macvlan mode bridge
ip netns exec yfcloud1 ip link set mv-1 up
ip netns  del yfcloud1


ip link add link enp2s0 dev mv-1 type macvlan mode bridge
ip link set mv-1 up
ip addr add 192.168.6.142/19 dev eth0

ip rule add from 192.168.6.142 table 2000
ip rule add from 192.168.100.83 table 2002
ip route add default via 192.168.100.6 table 2000


ip route add 192.168.100.0/24 dev mv-1 table 2000

ip route add 192.168.1.0/19 via 192.168.6.142 table 2000

ip route add default via 192.168.6.142 table 2000

ip route add default via 192.168.100.3 table 2004

ip route add 192.168.100.0 dev mv-4 table 2004


ip rule add from 192.168.100.6 table 2000
ip route add default via 192.168.100.6 table 2000
ip route add default via mv-1 table 2000

ip route del default table 2005
ip rule del table 2005
ip route del default table 2005
#ip rule add from 192.168.100.6 table 2006
#ip route add default via 192.168.100.6 table 2006

ip link add link enp2s0 dev mv-5 type macvlan mode bridge
ip link set mv-5 up
ip rule add from 192.168.100.83 table 2002
ip route add default via 192.168.100.83 table 2002

ip link del mv-5
ip rule del table 2005

ip route del default table 005

ip route add default via 192.168.100.30 dev enp2s0  src 192.168.100.30 table 2005


ip link add link enp2s0 dev mv-6 type macvlan mode bridge
ip link set mv-6 up
ip rule add from 192.168.100.83 table 2002

ip route add 192.168.100.0/24 dev mv-2 table 2002
ip route add default via 192.168.100.1 dev mv-2 src 192.168.100.83 table 2002

ip link add link enp2s0 dev mv-5 type macvlan mode private


ip link add link enp2s0 ipvl0 type ipvlan mode l2
ip link add link enp2s0 ipvl1 type ipvlan mode l2


192.168.100.0/24 dev mv-5  scope link src 192.168.100.30


ip link add link enp2s0 dev mv-5 type macvlan mode bridge
ip rule add to 192.168.100.66 table 2005
ip route add 192.168.100.0/24 dev mv-5  proto kernel scope link src 192.168.100.66 table 2005
ip route add 192.168.100.0/24 dev mv-5  dev mv-1 src 192.168.100.33  table 2001
ip route add default via 192.168.100.1 dev mv-1 table 2001
ip route del 192.168.100.0/24 dev mv-1  proto kernel scope link src 192.168.100.66 table 2005

ip route add default via 192.168.100.1 dev mv-1 table 2001
ip route add 192.168.100.0/24 dev mv-1  proto kernel scope link src 192.168.100.10 table 2001
ip route del default via 192.168.100.1 dev mv-1 table 2001
ip route del 192.168.100.0/24 dev mv-1  proto kernel scope link src 192.168.100.33 table 2001


default via 192.168.100.1 dev mv-5 src 192.168.100.30
192.168.100.0/24 via  192.168.100.61 dev mv-6 proto kernel scope link src 192.168.100.61

192.168.100.0/24 via  192.168.100.61 dev mv-6 proto kernel scope link src 192.168.100.30


ip route add default via 192.168.100.1 dev enp2s0 proto dhcp src 192.168.100.2 metric 100
ip route add 192.168.100.0/24 dev enp2s0 proto kernel scope link src 192.168.100.2


ip route add default via 192.168.100.1 dev mv-6  src 192.168.100.61

ip route add 192.168.100.0/24 via 192.168.100.1 dev mv-5



vconfig add enp2s0 100
vconfig add enp2s0 200
vconfig set_flag enp2s0.100 1 1
vconfig set_flag enp2s0.200 1 1

ifconfig enp2s0.100 up
ifconfig enp2s0.200 up

ip link add link enp2s0.100 dev mv-1 type macvlan mode bridge
ip link add link enp2s0.200 dev mv-2 type macvlan mode bridge
ip link set mv-1 up
ip link set mv-2 up

root@ubuntu:~# docker network create -d macvlan --subnet=172.16.10.0/24 --gateway=172.16.10.1 -o parent=enp2s0.100 mac10
root@ubuntu:~# docker network create -d macvlan --subnet=172.16.20.0/24 --gateway=172.16.20.1 -o parent=enp2s0.200 mac20

sudo ip addr add 192.168.100.3/24 dev enp2s0.1
sudo ip link set dev enp2s0.1 up


ip link add link ens1 iv-1 type ipvlan mode l2

sysctl -w net.ipv4.conf.all.arp_ignore=1
sysctl -w net.ipv4.conf.all.arp_announce=2
sysctl -w net.ipv4.conf.all.rp_filter=2


ip link add link em1 dev mv-100 type macvlan mode bridge

ip link add link enp2s0 name enp2s0.1 type vlan id 1


ip link add link em4 name em4.100 type vlan id 100
ip link set em4.100 up
# 创建 macvlan
ip link add link em4.100 dev mv-6 type macvlan mode bridge
ip link set mv-6 up
#创建 网络空间
ip netns add yfcloud6
# 连接 macvlan 和网络空间
ip link set mv-6 netns yfcloud6
# 网络空间内拨号
pppd plugin /usr/lib64/pppd/2.4.5/rp-pppoe.so mv-6 noipdefault noauth default-asyncmap hide-password nodetach mtu 1460 mru 1460 noaccomp  nodeflate nopcomp novj novjccomp user 38800673269 lcp-echo-interval 20 lcp-echo-failure 100 lcp-echo-failure 100 unit 0 debug



ip link add link enp2s0 dev mv-1 type macvlan mode bridge
ip netns exec yfcloud1 ip link set mv-1 up
ip netns  del yfcloud1
